<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');



class Config extends MY_Controller{

    public function __construct() {
        parent::__construct();
        $this->acl_auth->restrict_access('admin');
    }
    
    /**
     * Only login user have access on this one
     */
	public function index(){
        
        $this->load->model('config_model', 'dbconfig');
        
        //landing page
        $d=array();
        $d['title']='Configuration';
        $d['_configs']=$this->dbconfig->get_config();
        $views['_tabs'] = 'user/tabs';
        //$views['_userform'] = 'user/user_form';
        $views['_content'] = 'user/config';
        $this->template->load('user/admin', $views, $d);    

    }
    
    public function config(){
        $this->index();
    }
    
    public function update()
    {
        $this->load->model('config_model', 'cofig');
        if ($this->isPost()){
            if ($this->cofig->save($_POST)){
                $this->session->set_flashdata('success','Successfully save.');
            }else{
                $this->session->set_flashdata('error','Successfully save.');
            }
            
        }
        redirect("config/config");
    }
    
}
